package com.snowj.apaas.repository.auto;

import static com.snowj.apaas.repository.auto.GroupMembersDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.snowj.apaas.domain.auto.GroupMembers;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface GroupMembersMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.258151+08:00", comments="Source Table: group_members")
    BasicColumn[] selectList = BasicColumn.columnList(id, username, groupId);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.257347+08:00", comments="Source Table: group_members")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.257388+08:00", comments="Source Table: group_members")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.25746+08:00", comments="Source Table: group_members")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<GroupMembers> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.257537+08:00", comments="Source Table: group_members")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<GroupMembers> multipleInsertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.257613+08:00", comments="Source Table: group_members")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("GroupMembersResult")
    Optional<GroupMembers> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.257661+08:00", comments="Source Table: group_members")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="GroupMembersResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="username", property="username", jdbcType=JdbcType.VARCHAR),
        @Result(column="group_id", property="groupId", jdbcType=JdbcType.BIGINT)
    })
    List<GroupMembers> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.257746+08:00", comments="Source Table: group_members")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.257788+08:00", comments="Source Table: group_members")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, groupMembers, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.257829+08:00", comments="Source Table: group_members")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, groupMembers, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.257869+08:00", comments="Source Table: group_members")
    default int deleteByPrimaryKey(Long id_) {
        return delete(c -> 
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.257911+08:00", comments="Source Table: group_members")
    default int insert(GroupMembers record) {
        return MyBatis3Utils.insert(this::insert, record, groupMembers, c ->
            c.map(id).toProperty("id")
            .map(username).toProperty("username")
            .map(groupId).toProperty("groupId")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.257974+08:00", comments="Source Table: group_members")
    default int insertMultiple(Collection<GroupMembers> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, groupMembers, c ->
            c.map(id).toProperty("id")
            .map(username).toProperty("username")
            .map(groupId).toProperty("groupId")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.258053+08:00", comments="Source Table: group_members")
    default int insertSelective(GroupMembers record) {
        return MyBatis3Utils.insert(this::insert, record, groupMembers, c ->
            c.map(id).toPropertyWhenPresent("id", record::getId)
            .map(username).toPropertyWhenPresent("username", record::getUsername)
            .map(groupId).toPropertyWhenPresent("groupId", record::getGroupId)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.258198+08:00", comments="Source Table: group_members")
    default Optional<GroupMembers> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, groupMembers, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.258253+08:00", comments="Source Table: group_members")
    default List<GroupMembers> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, groupMembers, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.258299+08:00", comments="Source Table: group_members")
    default List<GroupMembers> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, groupMembers, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.258342+08:00", comments="Source Table: group_members")
    default Optional<GroupMembers> selectByPrimaryKey(Long id_) {
        return selectOne(c ->
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.258386+08:00", comments="Source Table: group_members")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, groupMembers, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.258427+08:00", comments="Source Table: group_members")
    static UpdateDSL<UpdateModel> updateAllColumns(GroupMembers record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalTo(record::getId)
                .set(username).equalTo(record::getUsername)
                .set(groupId).equalTo(record::getGroupId);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.258503+08:00", comments="Source Table: group_members")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(GroupMembers record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalToWhenPresent(record::getId)
                .set(username).equalToWhenPresent(record::getUsername)
                .set(groupId).equalToWhenPresent(record::getGroupId);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.258599+08:00", comments="Source Table: group_members")
    default int updateByPrimaryKey(GroupMembers record) {
        return update(c ->
            c.set(username).equalTo(record::getUsername)
            .set(groupId).equalTo(record::getGroupId)
            .where(id, isEqualTo(record::getId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.258703+08:00", comments="Source Table: group_members")
    default int updateByPrimaryKeySelective(GroupMembers record) {
        return update(c ->
            c.set(username).equalToWhenPresent(record::getUsername)
            .set(groupId).equalToWhenPresent(record::getGroupId)
            .where(id, isEqualTo(record::getId))
        );
    }
}